/*********************************************************************
**********************************************************************
*                                                                    *
*                                                                    *
**********************************************************************
*/

#include "stdio.h"
#include "DIALOG.h"

extern GUI_CONST_STORAGE GUI_FONT GUI_FontConsolas30;

extern GUI_CONST_STORAGE GUI_BITMAP bmbutton_press;
extern GUI_CONST_STORAGE GUI_BITMAP bmbutton_pon;
extern GUI_CONST_STORAGE GUI_BITMAP bmIcon_OS_64x64;
extern GUI_CONST_STORAGE GUI_BITMAP bmpress_on;
extern GUI_CONST_STORAGE GUI_BITMAP bmbt_bk_10040;

#define DEC_TRANSPARENT(x)      ((unsigned long)(x*255/100)<<24)
#define COLOR_NONE              DEC_TRANSPARENT(100)
#define COLOR_MK(CR, TRAN)      (CR | DEC_TRANSPARENT(TRAN))

// 画风颜色定义
#define FRAME_DISABLED_COLOR0           ( GUI_GRAY | DEC_TRANSPARENT(0) )
#define FRAME_DISABLED_COLOR1           ( GUI_GRAY | DEC_TRANSPARENT(0) )
#define FRAME_DISABLED_COLOR2           ( GUI_GRAY | DEC_TRANSPARENT(0) )

#define FRAME_ENABLED_COLOR0           ( GUI_LIGHTBLUE | DEC_TRANSPARENT(25) )           
#define FRAME_ENABLED_COLOR1           ( GUI_DARKBLUE | DEC_TRANSPARENT(25) )
#define FRAME_ENABLED_COLOR2           ( GUI_LIGHTBLUE | DEC_TRANSPARENT(25) )

#define FRAME_FOCUSED_COLOR0           ( GUI_LIGHTGREEN | DEC_TRANSPARENT(50) )
#define FRAME_FOCUSED_COLOR1           ( GUI_DARKBLUE | DEC_TRANSPARENT(25) )
#define FRAME_FOCUSED_COLOR2           ( GUI_LIGHTBLUE | DEC_TRANSPARENT(25) )

#define FRAME_UNPRESSED_COLOR0         ( GUI_LIGHTBLUE | DEC_TRANSPARENT(25) )
#define FRAME_UNPRESSED_COLOR1         ( GUI_DARKBLUE | DEC_TRANSPARENT (25) )
#define FRAME_UNPRESSED_COLOR2         ( GUI_LIGHTBLUE | DEC_TRANSPARENT(25) )

#define FRAME_PRESSED_COLOR0           ( GUI_LIGHTGREEN | DEC_TRANSPARENT(25) )
#define FRAME_PRESSED_COLOR1           ( GUI_LIGHTBLUE | DEC_TRANSPARENT (25) )
#define FRAME_PRESSED_COLOR2           ( GUI_LIGHTGREEN | DEC_TRANSPARENT(25) )


#define ARROW_DISABLED_COLOR			( GUI_GRAY | DEC_TRANSPARENT(0) )
#define ARROW_ENABLED_COLOR				( GUI_BLACK | DEC_TRANSPARENT(0) )
#define ARROW_FOCUSED_COLOR				( GUI_BLACK | DEC_TRANSPARENT(0) )
#define ARROW_PRESSED_COLOR				( GUI_BLACK | DEC_TRANSPARENT(0) )
#define ARROW_UNPRESSED_COLOR			( GUI_BLACK | DEC_TRANSPARENT(0) )

// 
#define OPT_FILL_MID_COLOR              ( GUI_LIGHTBLUE | DEC_TRANSPARENT(0) )
#define OPT_FILL_EXT_COLOR              ( GUI_DARKBLUE | DEC_TRANSPARENT(0) )

#define TEXT_BK_COLOR                   ( GUI_DARKBLUE | DEC_TRANSPARENT(0) )       
#define TEXT_FR_COLOR                   ( GUI_WHITE | DEC_TRANSPARENT(0) )  


#define PAR_TEXT_COLOR                  (GUI_WHITE | DEC_TRANSPARENT(0))
#define PAR_BUTTON_EXT_COLOR            (GUI_LIGHTBLUE | DEC_TRANSPARENT(50)) 
#define PAR_BUTTON_MID_COLOR            (0xFFC0C0 | DEC_TRANSPARENT(50)) 
#define PAR_VALUE_COLOR                 (GUI_WHITE | DEC_TRANSPARENT(0))
#define PAR_VALUE_FRAME_COLOR              (GUI_LIGHTBLUE | DEC_TRANSPARENT(50))
#define PAR_VALUE_BK_EXT_COLOR             (GUI_LIGHTBLUE | DEC_TRANSPARENT(70))
#define PAR_VALUE_BK_MID_COLOR             (GUI_LIGHTBLUE | DEC_TRANSPARENT(70))
#define PAR_SEL_BK_COLOR                   (GUI_BLUE | DEC_TRANSPARENT(0))

/*****************************************************************************
* @brief   WM_SetCallback 模式皮肤绘制.
*****************************************************************************/
void _cbButton0(WM_MESSAGE * pMsg)
{
	WM_HWIN hWin;
	hWin = pMsg->hWin;
	switch (pMsg->MsgId)
	{
		case WM_PAINT:
			if (BUTTON_IsPressed(hWin))
			{
				GUI_SetBkColor(GUI_WHITE | DEC_TRANSPARENT(100));
				GUI_SetColor(GUI_BLACK);
				GUI_SetFont(&GUI_Font16B_ASCII);

				//GUI_Clear();
				GUI_SetAlpha(0xb0);
				//GUI_DrawBitmap(&bmbutton_press, 8, 8);
				GUI_SetAlpha(0);
				GUI_DispStringAt("BACK",3,3);
			}
			else
			{
				GUI_SetBkColor(GUI_WHITE | DEC_TRANSPARENT(100));
				GUI_SetColor(GUI_BLACK);
				GUI_SetFont(&GUI_Font16B_ASCII);

				//GUI_DrawBitmap(&bmbutton_pon, 8, 8);
				GUI_DispStringAt("BACK", 3, 3);
			}
			break;
		default:
			BUTTON_Callback(pMsg);
	}
}

/*****************************************************************************
* @brief   WM_SetCallback 模式皮肤绘制.
*****************************************************************************/
void _cbButton1(WM_MESSAGE * pMsg)
{
	WM_HWIN hWin;
	GUI_RECT Rect;
	hWin = pMsg->hWin;
	switch (pMsg->MsgId)
	{
		case WM_PAINT:
			WM_GetClientRect(&Rect);
			if (BUTTON_IsPressed(hWin))
			{
				GUI_SetColor(GUI_DARKGRAY);
				GUI_FillRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 5);
				GUI_SetBkColor(GUI_DARKGRAY);
				GUI_SetColor(GUI_WHITE);
			}
			else
			{
				GUI_SetColor(GUI_LIGHTBLUE);
				GUI_FillRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 5);
				GUI_SetBkColor(GUI_LIGHTBLUE);
				GUI_SetColor(GUI_WHITE);
			}
			GUI_SetFont(&GUI_Font16_ASCII);
			GUI_DispStringInRect("LED1", &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);
			break;
		default:
			BUTTON_Callback(pMsg);
	}
}

/*****************************************************************************
* @brief   button 经典模式皮肤设置.
*****************************************************************************/
void button_skin_set(WM_HMEM hItem, short x, short y)
{
	// 设置字体
	BUTTON_SetFont(hItem, GUI_FONT_20B_ASCII);
	// 文字对齐方式
	BUTTON_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
	// 文字颜色
	BUTTON_SetTextColor(hItem, BUTTON_CI_DISABLED, GUI_GRAY);
	BUTTON_SetTextColor(hItem, BUTTON_CI_PRESSED, GUI_BROWN);
	BUTTON_SetTextColor(hItem, BUTTON_CI_UNPRESSED, GUI_BROWN);

	// 设置背景色 注意：颜色设置必须在Classic模式才有效, 系统默认为新皮肤
	// 透明色支持需要系统开启透明通道支持
	//BUTTON_SetSkinClassic(hItem);
	BUTTON_SetBkColor(hItem, BUTTON_CI_DISABLED, 0x77777777);
	BUTTON_SetBkColor(hItem, BUTTON_CI_PRESSED, GUI_LIGHTBLUE | DEC_TRANSPARENT(25));
	BUTTON_SetBkColor(hItem, BUTTON_CI_UNPRESSED, GUI_BLUE | DEC_TRANSPARENT(75));

	// 设置按钮框的颜色
	BUTTON_SetFrameColor(hItem, GUI_LIGHTGREEN | DEC_TRANSPARENT(75));

	// 显示图片，三种接口，所使用的图像格式不同
	//BUTTON_SetBitmap(hItem, BUTTON_BI_PRESSED, &bmbutton_pon);
	//BUTTON_SetBitmap(hItem, BUTTON_BI_UNPRESSED, &bmbutton_press);
	BUTTON_SetBitmapEx(hItem, BUTTON_BI_PRESSED, &bmpress_on, (x - bmpress_on.XSize) >> 1, (y - bmpress_on.YSize) >> 1);
	BUTTON_SetBitmapEx(hItem, BUTTON_BI_UNPRESSED, &bmpress_on, (x - bmpress_on.XSize) >> 1, (y - bmpress_on.YSize) >> 1);
	//BUTTON_SetStreamedBitmap
	//BUTTON_SetBMP

	WM_SetHasTrans(hItem);
}


/*****************************************************************************
* @brief   button FLEX模式皮肤自定义设置.
*****************************************************************************/
int  button_skin_key(const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
	WM_HWIN hWin;
	int x, y;
	GUI_RECT Rect;
	hWin = pDrawItemInfo->hWin;

	switch (pDrawItemInfo->Cmd)
	{
		case WIDGET_ITEM_CREATE:
			//GUI_DrawBitmap(&bmbutton_pon,0,0);
			break;
		case WIDGET_ITEM_DRAW_BACKGROUND:
			if (BUTTON_IsPressed(hWin))
			{
			}
			else
			{
			}
			break;
		case WIDGET_ITEM_DRAW_BITMAP:
			
			if (BUTTON_IsPressed(hWin))
			{
				GUI_SetColor(FRAME_PRESSED_COLOR0);

				GUI_DrawRoundedRect(
					pDrawItemInfo->x0,
					pDrawItemInfo->y0,
					pDrawItemInfo->x1,
					pDrawItemInfo->y1,
					3
					);
			}
			else
			{
			}
			break;
		case WIDGET_ITEM_DRAW_TEXT:

			break;
		default:
			break;
	}
}

/*****************************************************************************
* @brief   button 经典模式皮肤设置.
*****************************************************************************/
void button_skin_at_keyboard(WM_HMEM hItem, short x, short y)
{
	BUTTON_SetSkin(hItem, button_skin_key);
}


/*****************************************************************************
* @brief   button FLEX模式皮肤自定义设置.
*****************************************************************************/
static const char * button_text;
int  button_skin_self_def0 (const WIDGET_ITEM_DRAW_INFO * pDrawItemInfo)
{
	WM_HWIN hWin;
	int x, y;
	GUI_RECT Rect;
	hWin = pDrawItemInfo->hWin;

	switch (pDrawItemInfo->Cmd)
	{
		case WIDGET_ITEM_CREATE:
			//GUI_DrawBitmap(&bmbutton_pon,0,0);
			break;
		case WIDGET_ITEM_DRAW_BACKGROUND:
			if (BUTTON_IsPressed(hWin))
			{
				GUI_DrawBitmap(&bmbt_bk_10040, 0, 0);
				GUI_SetColor(COLOR_MK(GUI_DARKGREEN, 25));
				GUI_DrawRoundedRect(0, 0, pDrawItemInfo->x1, pDrawItemInfo->y1,3);
			}
			else
			{
				GUI_DrawBitmap(&bmbt_bk_10040, 0, 0);
			}
			break;
		case WIDGET_ITEM_DRAW_BITMAP:
			
			if (BUTTON_IsPressed(hWin))
			{
				x = (pDrawItemInfo->x0 + pDrawItemInfo->x1 - bmpress_on.XSize) >> 1;
				y = (pDrawItemInfo->y0 + pDrawItemInfo->y1 - bmpress_on.YSize) >> 1;
				GUI_DrawBitmap(&bmpress_on, x, y);
			}
			else
			{
				x = (pDrawItemInfo->x0 + pDrawItemInfo->x1 - bmpress_on.XSize) >> 1;
				y = (pDrawItemInfo->y0 + pDrawItemInfo->y1 - bmpress_on.YSize) >> 1;
				GUI_DrawBitmap(&bmpress_on, x, y);
			}
			break;
		case WIDGET_ITEM_DRAW_TEXT:
			GUI_SetBkColor(GUI_WHITE | DEC_TRANSPARENT(100));
			if (BUTTON_IsPressed(hWin))
				GUI_SetColor(GUI_BLACK);
			else
				GUI_SetColor(GUI_BLUE);
			GUI_SetFont(&GUI_Font16B_ASCII);
			x = (pDrawItemInfo->x0 + pDrawItemInfo->x1) >> 1;
			y = (pDrawItemInfo->y0 + pDrawItemInfo->y1 - 16) >> 1;

			GUI_DispStringHCenterAt(button_text, x, y);
			break;
		default:
			break;
	}
}

/*****************************************************************************
* @brief   button皮肤选择.
*****************************************************************************/
void button_skin_self_sel(WM_HMEM hItem, char skin_sel, const char *text)
{
	button_text = text;

	switch (skin_sel)
	{
		case 0:
			BUTTON_SetSkin(hItem, button_skin_self_def0);
			break;
	}
}

/*****************************************************************************
* @brief   button 默认FLEX皮肤设置.
*****************************************************************************/
void button_skin_default_set(void)
{
	BUTTON_SKINFLEX_PROPS BUTTON_Props;

	BUTTON_SetDefaultBkColor(GUI_RED, BUTTON_CI_DISABLED);
	BUTTON_SetDefaultBkColor(GUI_RED, BUTTON_CI_UNPRESSED);
	BUTTON_SetDefaultBkColor(GUI_RED, BUTTON_CI_PRESSED);

	// 皮肤
	/* 获取按钮启动状态的皮肤 */
	BUTTON_GetSkinFlexProps(&BUTTON_Props, BUTTON_SKINFLEX_PI_ENABLED);
	BUTTON_Props.aColorFrame[0] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [0] - 环绕框架的外部颜色。
	BUTTON_Props.aColorFrame[2] = GUI_LIGHTRED | DEC_TRANSPARENT(25);  // [2] - 框架与内部矩形区域之间区域的颜色。
	BUTTON_Props.aColorFrame[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 环绕框架的内部颜色
	BUTTON_Props.aColorLower[1] = GUI_LIGHTRED | DEC_TRANSPARENT(25); // [1] - 上层梯度色的结束色。
	BUTTON_Props.aColorLower[0] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [0] - 上层梯度色的起始色。
	BUTTON_Props.aColorUpper[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 下层梯度色的结束色
	BUTTON_Props.aColorUpper[0] = GUI_LIGHTRED | DEC_TRANSPARENT(25); // [0] - 下层梯度色的起始色

	BUTTON_Props.Radius = 4;
	/* 设置按下启动状态的皮肤色 */
	BUTTON_SetSkinFlexProps(&BUTTON_Props, BUTTON_SKINFLEX_PI_ENABLED);

	/* 设置聚焦状态的皮肤色 */
	BUTTON_Props.aColorFrame[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(50);  // [0] - 环绕框架的外部颜色。
	BUTTON_SetSkinFlexProps(&BUTTON_Props, BUTTON_SKINFLEX_PI_FOCUSSED);

	BUTTON_Props.aColorFrame[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25); // [0] - 环绕框架的外部颜色。
	BUTTON_Props.aColorFrame[2] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25); // [2] - 框架与内部矩形区域之间区域的颜色。
	BUTTON_Props.aColorFrame[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 环绕框架的内部颜色
	BUTTON_Props.aColorLower[0] = GUI_DARKBLUE | DEC_TRANSPARENT(40);  // [0] - 上层梯度色的起始色。
	BUTTON_Props.aColorLower[1] = GUI_LIGHTBLUE | DEC_TRANSPARENT(40); // [1] - 上层梯度色的结束色。
	BUTTON_Props.aColorUpper[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(40); // [0] - 下层梯度色的起始色
	BUTTON_Props.aColorUpper[1] = GUI_DARKBLUE | DEC_TRANSPARENT(40);  // [1] - 下层梯度色的结束色
	
	/* 设置按下状态的皮肤色 */
	BUTTON_SetSkinFlexProps(&BUTTON_Props, BUTTON_SKINFLEX_PI_PRESSED); 
}

/*****************************************************************************
* @brief   滑动条 经典皮肤设置.
*****************************************************************************/
void scrollbar_skin_set(WM_HMEM hItem, short x, short y)
{
	 //SCROLLBAR_SetSkinClassic(hItem);

	 SCROLLBAR_SetValue(hItem, 45);
	 SCROLLBAR_SetColor(hItem, SCROLLBAR_CI_THUMB, GUI_BLUE);
	 SCROLLBAR_SetColor(hItem, SCROLLBAR_CI_SHAFT, GUI_GRAY);
	 SCROLLBAR_SetColor(hItem, SCROLLBAR_CI_ARROW, GUI_BLACK);
}

/*****************************************************************************
* @brief   滑动条 默认FLEX皮肤设置.
*****************************************************************************/
void scrollbar_default_skin_set(void)
{
	SCROLLBAR_SKINFLEX_PROPS Props;

	// 皮肤
	/* 获取按钮启动状态的皮肤 */
	SCROLLBAR_GetSkinFlexProps(&Props, SCROLLBAR_SKINFLEX_PI_UNPRESSED);
	Props.aColorFrame[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25);  // [0] - 环绕框架的外部颜色。
	Props.aColorFrame[2] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25);  // [2] - 框架与内部矩形区域之间区域的颜色。
	Props.aColorFrame[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 环绕框架的内部颜色
	Props.aColorLower[0] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [0] - 上层梯度色的起始色。
	Props.aColorLower[1] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25); // [1] - 上层梯度色的结束色。
	Props.aColorUpper[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25); // [0] - 下层梯度色的起始色
	Props.aColorUpper[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 下层梯度色的结束色
	Props.aColorShaft[0] = GUI_LIGHTGRAY | DEC_TRANSPARENT(25);  // [0] - 轴渐变的顶部颜色
	Props.aColorShaft[1] = GUI_LIGHTGRAY | DEC_TRANSPARENT(25);  // [1] - 轴渐变的底部颜色
	Props.ColorArrow = GUI_DARKBLUE;
	Props.ColorGrasp = GUI_DARKBLUE;
	SCROLLBAR_SetSkinFlexProps(&Props, SCROLLBAR_SKINFLEX_PI_UNPRESSED);

	SCROLLBAR_GetSkinFlexProps(&Props, SCROLLBAR_SKINFLEX_PI_PRESSED);
	Props.aColorFrame[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25);  // [0] - 环绕框架的外部颜色。
	Props.aColorFrame[2] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25);  // [2] - 框架与内部矩形区域之间区域的颜色。
	Props.aColorFrame[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 环绕框架的内部颜色
	Props.aColorLower[0] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [0] - 上层梯度色的起始色。
	Props.aColorLower[1] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25); // [1] - 上层梯度色的结束色。
	Props.aColorUpper[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(25); // [0] - 下层梯度色的起始色
	Props.aColorUpper[1] = GUI_DARKBLUE | DEC_TRANSPARENT(25);  // [1] - 下层梯度色的结束色
	Props.aColorShaft[0] = GUI_LIGHTGRAY | DEC_TRANSPARENT(25);  // [0] - 轴渐变的顶部颜色
	Props.aColorShaft[1] = GUI_LIGHTGRAY | DEC_TRANSPARENT(25);  // [1] - 轴渐变的底部颜色
	Props.ColorArrow = GUI_DARKBLUE; // 箭头颜色
	Props.ColorGrasp = GUI_DARKBLUE; // 抓取点颜色
	SCROLLBAR_SetSkinFlexProps(&Props, SCROLLBAR_SKINFLEX_PI_PRESSED);
}

/*****************************************************************************
* @brief   进度条 默认FLEX皮肤设置.
*****************************************************************************/
void proglbar_default_skin_set(void)
{
	PROGBAR_SKINFLEX_PROPS Props;

	PROGBAR_GetSkinFlexProps(&Props, 0);

	Props.aColorLowerL[1] = GUI_DARKGREEN | DEC_TRANSPARENT(0); // 
	Props.aColorLowerL[0] = GUI_LIGHTGREEN | DEC_TRANSPARENT(0);  // 
	Props.aColorUpperL[1] = GUI_LIGHTGREEN | DEC_TRANSPARENT(0);  // 
	Props.aColorUpperL[0] = GUI_DARKGREEN | DEC_TRANSPARENT(0); // 

	Props.aColorLowerR[1] = GUI_LIGHTBLUE | DEC_TRANSPARENT(80); // 
	Props.aColorLowerR[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	Props.aColorUpperR[1] = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	Props.aColorUpperR[0] = GUI_LIGHTBLUE | DEC_TRANSPARENT(80); // 

	Props.ColorFrame = GUI_DARKGREEN | DEC_TRANSPARENT(25);
	Props.ColorText = GUI_DARKBLUE | DEC_TRANSPARENT(25);

	PROGBAR_SetSkinFlexProps(&Props, 0);
}


/*****************************************************************************
* @brief   数据框 默认 flex 皮肤.
*****************************************************************************/
void spin_box_default_skin_set(void)
{
	SPINBOX_SKINFLEX_PROPS Props;

	// 按下状态
	SPINBOX_GetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_PRESSED);

	Props.aColorFrame[0] = FRAME_PRESSED_COLOR0; // 
	Props.aColorFrame[1] = FRAME_PRESSED_COLOR1;  // 
	Props.aColorFrame[2] = FRAME_PRESSED_COLOR2;  // 

	Props.ColorArrow = ARROW_PRESSED_COLOR; // 
	Props.ColorBk = GUI_LIGHTBLUE | DEC_TRANSPARENT(80); // 
	Props.ColorText = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	Props.ColorButtonFrame = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	SPINBOX_SetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_PRESSED);

	// 聚焦状态
	SPINBOX_GetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_FOCUSED);

	Props.aColorFrame[0] = FRAME_FOCUSED_COLOR0; // 
	Props.aColorFrame[1] = FRAME_FOCUSED_COLOR1;  // 
	Props.aColorFrame[2] = FRAME_FOCUSED_COLOR2;  // 

	Props.ColorArrow = ARROW_FOCUSED_COLOR; // 
	Props.ColorBk = GUI_LIGHTBLUE | DEC_TRANSPARENT(80); // 
	Props.ColorText = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	Props.ColorButtonFrame = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	SPINBOX_SetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_FOCUSED);

	// 启用状态
	SPINBOX_GetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_ENABLED);

	Props.aColorFrame[0] = FRAME_ENABLED_COLOR0; // 
	Props.aColorFrame[1] = FRAME_ENABLED_COLOR1;  // 
	Props.aColorFrame[2] = FRAME_ENABLED_COLOR2;  // 

	Props.ColorArrow = ARROW_ENABLED_COLOR; // 
	Props.ColorBk = GUI_LIGHTBLUE | DEC_TRANSPARENT(80); // 
	Props.ColorText = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	Props.ColorButtonFrame = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	SPINBOX_SetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_ENABLED);

	// 禁用状态
	SPINBOX_GetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_DISABLED);

	Props.aColorFrame[0] = FRAME_DISABLED_COLOR0; // 
	Props.aColorFrame[1] = FRAME_DISABLED_COLOR1;  // 
	Props.aColorFrame[2] = FRAME_DISABLED_COLOR2;  // 

	Props.ColorArrow = ARROW_DISABLED_COLOR; // 
	Props.ColorBk = GUI_LIGHTBLUE | DEC_TRANSPARENT(80); // 
	Props.ColorText = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	Props.ColorButtonFrame = GUI_LIGHTBLUE | DEC_TRANSPARENT(50); // 
	SPINBOX_SetSkinFlexProps(&Props, SPINBOX_SKINFLEX_PI_DISABLED);
}

/*****************************************************************************
* @brief   滑动条 默认 flex 皮肤.
*****************************************************************************/
void slider_default_skin_set(void)
{
	SLIDER_SKINFLEX_PROPS Props;

	// 按下状态
	SLIDER_GetSkinFlexProps(&Props, SLIDER_SKINFLEX_PI_PRESSED);

	Props.aColorFrame[0] = COLOR_NONE; 
	Props.aColorFrame[1] = COLOR_NONE;  
	Props.aColorFrame[2] = COLOR_NONE;  

	Props.aColorInner[0] = COLOR_MK(GUI_LIGHTGREEN, 0);
	Props.aColorInner[1] = COLOR_MK(GUI_DARKGREEN, 0);

	Props.aColorShaft[0] = COLOR_MK(GUI_DARKGREEN, 0);
	Props.aColorShaft[1] = COLOR_MK(GUI_DARKGREEN, 0);
	Props.aColorShaft[2] = COLOR_MK(GUI_LIGHTGREEN, 50);
	
	Props.ColorTick = COLOR_MK(GUI_LIGHTRED, 0);
	Props.ColorFocus = COLOR_MK(GUI_LIGHTBLUE, 0);
	Props.TickSize = 5;
	Props.ShaftSize = 8;

	SLIDER_SetSkinFlexProps(&Props, SLIDER_SKINFLEX_PI_PRESSED);

	// 未按下状态
	SLIDER_GetSkinFlexProps(&Props, SLIDER_SKINFLEX_PI_UNPRESSED);

	Props.aColorFrame[0] = COLOR_NONE;
	Props.aColorFrame[1] = COLOR_NONE;
	Props.aColorFrame[2] = COLOR_NONE;

	Props.aColorInner[0] = COLOR_MK(GUI_LIGHTGREEN, 0);
	Props.aColorInner[1] = COLOR_MK(GUI_DARKGREEN, 0);

	Props.aColorShaft[0] = COLOR_MK(GUI_DARKGREEN, 0);
	Props.aColorShaft[1] = COLOR_MK(GUI_DARKGREEN, 0);
	Props.aColorShaft[2] = COLOR_MK(GUI_LIGHTGREEN, 0);

	Props.ColorTick = COLOR_MK(GUI_LIGHTRED, 0);
	Props.ColorFocus = COLOR_MK(GUI_LIGHTBLUE, 0);
	Props.TickSize = 5;
	Props.ShaftSize = 8;

	SLIDER_SetSkinFlexProps(&Props, SLIDER_SKINFLEX_PI_UNPRESSED);
}


/*****************************************************************************
* @brief   单选 控件.
*****************************************************************************/
void radio_default_skin_set(void)
{
	RADIO_SKINFLEX_PROPS Props;

	// 按下状态
	RADIO_GetSkinFlexProps(&Props, 0);

	Props.aColorButton[0] = COLOR_MK(GUI_GRAY, 0);
	Props.aColorButton[1] = COLOR_MK(GUI_WHITE, 0);
	Props.aColorButton[2] = COLOR_MK(GUI_GRAY, 0);
	Props.aColorButton[3] = COLOR_MK(GUI_LIGHTGREEN, 0);
	Props.ButtonSize = 20;

	RADIO_SetSkinFlexProps(&Props, 0);
}

void _cbpar_Button1(WM_MESSAGE * pMsg)
{
	WM_HWIN hWin;
	GUI_RECT Rect;
	hWin = pMsg->hWin;
	char text[32];

	switch (pMsg->MsgId)
	{
		case WM_PAINT:
			WM_GetClientRect(&Rect);
			if (BUTTON_IsPressed(hWin))
			{
#define PIXS_BD  3
				GUI_SetColor(PAR_BUTTON_EXT_COLOR);
				GUI_AA_SetFactor(4);
				GUI_SetPenSize(2);
				GUI_AA_FillRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 5);
				GUI_DrawGradientV(Rect.x0 + PIXS_BD, Rect.y0 + PIXS_BD, Rect.x1 - PIXS_BD, (Rect.y0 + Rect.y1) >> 1, PAR_BUTTON_EXT_COLOR, PAR_BUTTON_MID_COLOR);
				GUI_DrawGradientV(Rect.x0 + PIXS_BD, ((Rect.y0 + Rect.y1) >> 1)+1, Rect.x1 - PIXS_BD, Rect.y1 - PIXS_BD, PAR_BUTTON_MID_COLOR, PAR_BUTTON_EXT_COLOR);
			}
			else
			{
				GUI_SetColor(PAR_BUTTON_EXT_COLOR);
				GUI_AA_SetFactor(4);
				GUI_SetPenSize(2);
				GUI_AA_FillRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 5);
				GUI_DrawGradientV(Rect.x0 + PIXS_BD, Rect.y0 + PIXS_BD, Rect.x1 - PIXS_BD, (Rect.y0 + Rect.y1) >> 1, PAR_BUTTON_EXT_COLOR, PAR_BUTTON_MID_COLOR);
				GUI_DrawGradientV(Rect.x0 + PIXS_BD, ((Rect.y0 + Rect.y1) >> 1) + 1, Rect.x1 - PIXS_BD, Rect.y1 - PIXS_BD, PAR_BUTTON_MID_COLOR, PAR_BUTTON_EXT_COLOR);
			}
			GUI_SetColor(PAR_TEXT_COLOR);
			GUI_SetFont(&GUI_FontConsolas30);
			BUTTON_GetText(hWin, text, 32);
			GUI_SetTextMode(GUI_TM_TRANS);
			GUI_SetColor(GUI_WHITE);
			GUI_DispStringInRect(text, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);
			break;
		default:
			BUTTON_Callback(pMsg);
	}
}

void _cbpar_Button2(WM_MESSAGE * pMsg)
{
	WM_HWIN hWin;
	GUI_RECT Rect;
	hWin = pMsg->hWin;
	char text[32];

	switch (pMsg->MsgId)
	{
		case WM_PAINT:
			WM_GetClientRect(&Rect);
			if (BUTTON_IsPressed(hWin))
			{
				GUI_SetColor(PAR_VALUE_FRAME_COLOR);
				GUI_AA_SetFactor(4);
				GUI_SetPenSize(2);
				GUI_AA_DrawRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 5);
			}
			else
			{
				GUI_SetColor(PAR_VALUE_FRAME_COLOR);
				GUI_AA_SetFactor(4);
				GUI_SetPenSize(2);
				GUI_AA_DrawRoundedRect(Rect.x0, Rect.y0, Rect.x1, Rect.y1, 5);
			}

			GUI_SetColor(PAR_VALUE_COLOR);
			GUI_SetFont(&GUI_FontConsolas30);
			BUTTON_GetText(hWin, text, 32);
			GUI_SetTextMode(GUI_TM_TRANS);
			GUI_DispStringInRect(text, &Rect, GUI_TA_HCENTER | GUI_TA_VCENTER);
			break;
		default:
			BUTTON_Callback(pMsg);
	}
}

/*****************************************************************************
* @brief  参数TEXT
*****************************************************************************/
void par_text_skin_set(WM_HWIN          hItem)
{
	WM_SetCallback(hItem, _cbpar_Button1);
	/*
	BUTTON_SetFont(hItem, GUI_FONT_20_ASCII);
	BUTTON_SetTextColor(hItem, ,GUI_ORANGE);
	BUTTON_SetTextAlign(hItem, GUI_TA_VCENTER | GUI_TA_HCENTER);
	BUTTON_SetBkColor(hItem, GUI_BLUE);
	*/
}


void parval_text_skin_set(WM_HWIN          hItem)
{
	WM_SetCallback(hItem, _cbpar_Button2);
	/*
	BUTTON_SetFont(hItem, GUI_FONT_20_ASCII);
	BUTTON_SetTextColor(hItem, GUI_BLUE);
	BUTTON_SetTextAlign(hItem, GUI_TA_VCENTER | GUI_TA_LEFT);
	BUTTON_SetBkColor(hItem, GUI_GRAY);

	*/
}

void par_dropdown_skin_set(WM_HWIN          hItem)
{
	DROPDOWN_SKINFLEX_PROPS Props;

	DROPDOWN_SetFont(hItem, &GUI_FontConsolas30);
	DROPDOWN_SetTextColor(hItem, DROPDOWN_CI_UNSEL, PAR_VALUE_COLOR);
	DROPDOWN_SetTextColor(hItem, DROPDOWN_CI_SEL, PAR_VALUE_COLOR);
	DROPDOWN_SetTextColor(hItem, DROPDOWN_CI_SELFOCUS, PAR_VALUE_COLOR);
	DROPDOWN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
	DROPDOWN_SetAutoScroll(hItem, 1);
	DROPDOWN_SetSel(hItem, 2);
	DROPDOWN_SetScrollbarWidth(hItem, 30);
	DROPDOWN_SetBkColor(hItem, DROPDOWN_CI_UNSEL, PAR_VALUE_BK_MID_COLOR);
	DROPDOWN_SetBkColor(hItem, DROPDOWN_CI_SELFOCUS, PAR_SEL_BK_COLOR);
	DROPDOWN_SetBkColor(hItem, DROPDOWN_CI_SEL, PAR_SEL_BK_COLOR);

	DROPDOWN_SetUpMode(hItem, 0);

	DROPDOWN_GetSkinFlexProps(&Props, DROPDOWN_SKINFLEX_PI_ENABLED);
	Props.aColorFrame[0] = PAR_VALUE_FRAME_COLOR;
	Props.aColorFrame[1] = PAR_VALUE_FRAME_COLOR;
	Props.aColorFrame[2] = PAR_VALUE_FRAME_COLOR;
	Props.aColorUpper[0] = PAR_VALUE_BK_EXT_COLOR;
	Props.aColorUpper[1] = PAR_VALUE_BK_MID_COLOR;
	Props.aColorLower[0] = PAR_VALUE_BK_MID_COLOR;
	Props.aColorLower[1] = PAR_VALUE_BK_EXT_COLOR;
	Props.ColorArrow = ARROW_ENABLED_COLOR;
	Props.ColorSep = ARROW_ENABLED_COLOR;
	Props.ColorText = PAR_VALUE_COLOR;
	Props.Radius = 5;
	DROPDOWN_SetSkinFlexProps(&Props, DROPDOWN_SKINFLEX_PI_ENABLED);
	DROPDOWN_SetSkinFlexProps(&Props, DROPDOWN_SKINFLEX_PI_FOCUSED);
	DROPDOWN_SetSkinFlexProps(&Props, DROPDOWN_SKINFLEX_PI_EXPANDED);
	DROPDOWN_SetSkinFlexProps(&Props, DROPDOWN_SKINFLEX_PI_DISABLED);
}

#define COLOR_BK          GUI_DARKGRAY
#define COLOR_BORDER      0x880000
#define COLOR_FRAME       GUI_BLACK
#define COLOR_GRID        GUI_GRAY

void graph_skin_set(WM_HWIN          hItem)
{
	// 设置边框的尺寸
	GRAPH_SetBorder(hItem, 0, 0, 200, 100);
	GRAPH_SetAutoScrollbar(hItem, GUI_COORD_X, 1);
	GRAPH_SetAutoScrollbar(hItem, GUI_COORD_Y, 1);
	GRAPH_SetScrollValue(hItem, GUI_COORD_X, 0);
	GRAPH_SetScrollValue(hItem, GUI_COORD_Y, 0);

	// Adjust grid
	//
	GRAPH_SetGridVis(hItem, 1);
	GRAPH_SetGridDistX(hItem, 20);
	GRAPH_SetGridDistY(hItem, 20);
	GRAPH_SetLineStyleH(hItem, GUI_LS_SOLID);
	GRAPH_SetLineStyleV(hItem, GUI_LS_SOLID);
	WM_BringToBottom(hItem);

	WM_SetHasTrans(hItem);
	GRAPH_SetColor(hItem, COLOR_BK, GRAPH_CI_BK);
	GRAPH_SetColor(hItem, COLOR_BORDER, GRAPH_CI_BORDER);
	GRAPH_SetColor(hItem, COLOR_FRAME, GRAPH_CI_FRAME);
	GRAPH_SetColor(hItem, COLOR_GRID, GRAPH_CI_GRID);


	/*
	GRAPH_DATA_YT_AddValue(hItem, 5);
	GRAPH_DATA_YT_AddValue(hItem, 12);
	GRAPH_DATA_YT_AddValue(hItem, 7);
	GRAPH_DATA_YT_AddValue(hItem, 20);
	*/
}

/*************************** End of file ****************************/
